<?php

class m131023_075854_create_topic_table extends CDbMigration
{
	public function up()
	{
            $this->execute("
                CREATE TABLE IF NOT EXISTS `topic` (
                    `id` int(11) NOT NULL AUTO_INCREMENT,
                    `title` varchar(255) NOT NULL,
                    `content` text NOT NULL,
                    `categoryId` int(11) NOT NULL,
                    `imageId` int(11) DEFAULT '0',
                    `status` tinyint(4) NOT NULL DEFAULT '1',
                    `createTime` int(11) NOT NULL,
                    PRIMARY KEY (`id`)
                ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
                CREATE TABLE IF NOT EXISTS `topic_category` (
                    `id` int(11) NOT NULL AUTO_INCREMENT,
                    `name` varchar(200) NOT NULL,
                    PRIMARY KEY (`id`)
                ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;

                INSERT INTO `topic_category` (`id`, `name`) VALUES
                                            (1, 'Hỗ trợ'),
                                            (2, 'Bản tin'),
                                            (3, 'Tài liệu');                    
            ");
	}

	public function down()
	{
		echo "m131023_075854_create_topic_table does not support migration down.\n";
		return false;
	}

	/*
	// Use safeUp/safeDown to do migration with transaction
	public function safeUp()
	{
	}

	public function safeDown()
	{
	}
	*/
}